/**
 * 
 */
package domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;



/**
 * @author yfekih
 *
 */

@Entity
@Table(name = "TB_DRONE")
public class Drone implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3625515010706255161L;
	
	
	public Drone(){
		
	}
	
	
	public Drone(String numeroSerie, Flotte flotte) {
		this.numeroSerie = numeroSerie;
		this.flotte = flotte;
	}



	public final static String FLOTTE_MAPPING_NAME = "flotte";
	public final static String DRONE_MISSION_MAPPING_NAME = "drone"; 


	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", nullable =false)
	private Long id;
	
	@Column(name="numero_serie", unique = true)
	private String numeroSerie;
	
	@Transient
	private NavData navData;
	
	@OneToMany(mappedBy = DroneMission.MISSION_MAPPING_NAME, cascade = {CascadeType.REMOVE} )
	private Set<DroneMission> missions;
	
	@ManyToOne(fetch= FetchType.EAGER, targetEntity = Flotte.class, cascade = {CascadeType.PERSIST})
	@JoinColumn(name = Flotte.ID_FLOTTE)
	private Flotte flotte;
	


	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	

	/**
	 * @param caracteristique the caracteristique to set
	 */
	public void setNavData(NavData navData) {
		this.navData = navData;
	}

	/**
	 * @return the flotte
	 */
	public Flotte getFlotte() {
		return flotte;
	}

	/**
	 * @param flotte the flotte to set
	 */
	public void setFlotte(Flotte flotte) {
		this.flotte = flotte;
	}


}
